package com.budwk.app.sqfw.controllers.admin;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.alibaba.fastjson.JSONObject;
import com.budwk.app.sqfw.dto.SqfwFormSummaryWithFlowDTO;
import com.budwk.app.sqfw.models.Sqfw_formSummary;
import com.budwk.app.sqfw.services.MeetingMinutesService;
import com.budwk.app.sqfw.services.SecurityInvestigationService;
import com.budwk.app.sqfw.vo.Sqfw_formSummaryForAdminVO;
import com.budwk.starter.common.openapi.annotation.*;
import com.budwk.starter.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.*;

@IocBean
@At("/platform/sqfw/meetingMinutes")
@ApiDefinition(tag = "会议记录接口")
@Slf4j
public class MeetingMinutesController {

    @Inject
    private MeetingMinutesService meetingMinutesService;

    @Inject(value = "meetingMinutesService")
    private SecurityInvestigationService investigationService;

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "提交数据")
    @ApiFormParams(implementation = SqfwFormSummaryWithFlowDTO.class)
    @ApiResponses(implementation = Sqfw_formSummary.class)
    @SaCheckLogin
    public Result<?> addMeetingMinutes(@Param("..") SqfwFormSummaryWithFlowDTO reqVo) {
        log.info("MeetingMinutesController addMeetingMinutes param: {}", JSONObject.toJSONString(reqVo));
        return meetingMinutesService.addMeetingMinutes(reqVo);
    }

    @At
    @Ok("json")
    @GET
    @ApiOperation(name = "重新生成PDF")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "completeflowId",description = "工作流id",required = true, check = true)
    })
    @SaCheckLogin
    public Result<?> afreshGeneratePDF(@Param("completeflowId") String completeflowId) {
        return meetingMinutesService.afreshGeneratePDF(completeflowId);
    }

    @At
    @Ok("json")
    @GET
    @ApiOperation(name = "查询会议名称历史数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "a20",description = "会议名称",required = true, check = true)
    })
    @SaCheckLogin
    public Result<?> queryMeetNameHistory(@Param("a20") String a20) {
        log.info("MeetingMinutesController queryMeetNameHistory param: {}", a20);
        return meetingMinutesService.queryMeetNameHistory(a20);
    }

    @At
    @Ok("json")
    @GET
    @ApiOperation(name = "下载文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sqfwId",description = "社区服务id",required = true, check = true),
            @ApiImplicitParam(name = "code",description = "下载文件名称",required = true, check = true)
    })
    @SaCheckLogin
    public Result<?> downloadFile(@Param("sqfwId") String sqfwId, @Param("excelType") String excelType, @Param("code") String code) {
        log.info("MeetingMinutesController downloadFile param: {}", sqfwId);
        return meetingMinutesService.downloadFile(sqfwId, excelType, code);
    }

    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "后台管理系统任务列表查询")
    @ApiFormParams(implementation = Sqfw_formSummaryForAdminVO.class)
    @ApiResponses(implementation = Sqfw_formSummary.class)
    @SaCheckLogin
    public Result<?> listSummaryByPage(@Param("..") Sqfw_formSummaryForAdminVO forAdminVo) {
        log.info("MeetingMinutesController listSummaryByPage param: {}", JSONObject.toJSONString(forAdminVo));
        return investigationService.listSummaryByPage(forAdminVo);
    }

    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "查询导出：按照条件导出PDF,根据服务记录id数组生成pdf合集zip")
    @ApiFormParams(implementation = Sqfw_formSummaryForAdminVO.class)
    @SaCheckLogin
    public Result<?> generateServiceRecordPdfCollZipForBM(@Param("..") Sqfw_formSummaryForAdminVO bean) {
        return Result.data(investigationService.generateServiceRecordPdfCollZipForBM(bean));
    }

    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "查询导出：按照条件导出excel, 根据服务记录id和汇总Id数组生成Excel合集")
    @ApiFormParams(implementation = Sqfw_formSummaryForAdminVO.class)
    @SaCheckLogin
    public Result<?> generateServiceRecordExcelCollZipForBM(@Param("..") Sqfw_formSummaryForAdminVO bean) {
        return Result.data(investigationService.generateServiceRecordExcelCollZipForBM(bean));
    }

    @At()
    @Ok("json")
    @GET
    @ApiOperation(name = "获取文件类型名称")
    @ApiResponses
    @SaCheckLogin
    public Result<?> listDownFileTypes(@Param("sqfwId") String sqfwId) {
        return Result.data(meetingMinutesService.listDownFileTypes(sqfwId));
    }
}
